第 6 步:我们稍后会编写此函数。让我们构建在用户输入正确密码之前一直运行的函数。

  • 这个函数有两个参数——精灵和密码。它将包含我们的while 循环
  • ,在上面写着: MAIN FUNCTION的地方拖入Define Function with Docstring
  • my_function重命名为ask_for_password并在( )中输入text_sprite , password
  • 最后,将您的文档字符串更改为以下内容: """ Gets input until password is correct """

    To navigate the page using the TAB key, first press ESC to exit the code editor.

    # THIS ACTIVITY IS IN PREVIEW ONLY MODE
    • Run Code
    • Submit Work
    • Next Activity
    • Show Console
    • Reset Code Editor
    • Codesters How To (opens in a new tab)